//
//  PieChartViewController.m
//  饼线柱状图
//
//  Created by ma c on 9/8/18.
//  Copyright © 2018年 子房. All rights reserved.
//

#import "PieChartViewController.h"
#import "SSWPieChartView.h"

@interface PieChartViewController ()<SSWChartsDelegate>

@end

@implementation PieChartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self makeTheSSW];
}

-(void)makeTheSSW
{
    SSWPieChartView * ssw = [[SSWPieChartView alloc] initWithChartType:SSWChartsTypePie];
    ssw.bounds = CGRectMake(0, 0, 400, 400);
    ssw.center = self.view.center;
    ssw.delegate = self;
    ssw.colorsArr = @[[UIColor redColor],
                      [UIColor orangeColor],
                      [UIColor yellowColor],
                      [UIColor greenColor],
                      [UIColor cyanColor],
                      [UIColor blueColor],
                      [UIColor brownColor],
                      [UIColor darkGrayColor],
                      [UIColor grayColor],
                      [UIColor yellowColor]];//颜色数组
    
    ssw.titlesArr = @[@"小麦",
                      @"玉米",
                      @"大豆",
                      @"早籼稻",
                      @"旱籼稻",
                      @"小麦",
                      @"玉米",
                      @"大豆",
                      @"早籼稻"];//标题数组
    ssw.percentageArr = @[@"0.05",@"0.2",@"0.07",@"0.1",@"0.15",@"0.1",@"0.08",@"0.12",@"0.13"];
    
    [self.view addSubview:ssw];
}

-(void)SSWChartView:(SSWCharts *)chartView didSelectIndex:(NSInteger)index
{
    NSLog(@"点击的是(%ld)",index);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
